


$(function () {
    var cookieList_p=JSON.parse($.cookie("usePhone")||"[]");
    var cookieList_e=JSON.parse($.cookie("useEmail")||"[]");
    console.log(cookieList_e);
    console.log(cookieList_p);
    $(".toLogin").on("click",function () {
        if(cookieList_p.length>0){
            $(".login_box form:eq(0) [name=uname]").val(cookieList_p[0].phone);
            $(".login_box form:eq(0) [name=upwd]").val(cookieList_p[0].pwd)
        }
        if(cookieList_e.length>0){
            $(".login_box form:eq(1) [name=uemail]").val(cookieList_e[0].email);
            $(".login_box form:eq(1) [name=upwd]").val(cookieList_e[0].pwd)
        }
        // console.log(cookieList_e[0].email);
        $(".res_box").css("display", "none");
        $(".login_box").css("display", "block");

        $(".login_box form:eq(0)").on("submit",function () {
            $.ajax({
                type:"post",
                url:"http://127.0.0.1/1803/wangyinet/src/server/plogin.php",
                data:{
                    "uname":$(".login_box form:eq(0) [name=uname]").val(),
                    "upwd":$(".login_box form:eq(0) [name=upwd]").val(),
                },
                dataType:"json"
            }).then(function (res) {
                var arrCookie=[];
                if($(".phone_cxb")[0].checked){
                    var data={"phone":$(".login_box form:eq(0) [name=uname]").val(),pwd:$(".login_box form:eq(0) [name=upwd]").val()};
                    arrCookie.push(data);
                    $.cookie("usePhone",JSON.stringify(arrCookie),10);
                }

                if (res.status==1){
                    $(location).prop("href","../client/index.html")
                } else {
                    alert(res.msg)
                }
            });
            return false
        })


        $(".login_box form:eq(1)").on("submit",function () {
            $.ajax({
                type:"post",
                url:"http://127.0.0.1/1803/wangyinet/src/server/elogin.php",
                data:{
                    "uename":$(".login_box form:eq(1) [name=uemail]").val(),
                    "upwd":$(".login_box form:eq(1) [name=upwd]").val(),
                },
                dataType:"json"
            }).then(function (res) {

                var arrCookie=[];
                if($(".email_cxb")[0].checked){
                    var data={"email":$(".login_box form:eq(1) [name=uemail]").val(),pwd:$(".login_box form:eq(1) [name=upwd]").val()};
                    arrCookie.push(data);
                    $.cookie("useEmail",JSON.stringify(arrCookie),10);
                }
                if (res.status==1){
                    $(location).prop("href","../client/index.html")
                } else {
                    alert(res.msg)
                }
            });
            return false
        })
    })

});